<template>
  <div>
    <el-dialog
      :title="title"
      :visible="dialogVisible"
      :show-close="false"
      width="500px"
    >
      <el-form
        ref="passwordDialog"
        :model="form"
        :rules="rules"
        label-width="120px"
      >
        <el-form-item label="密码:" prop="password" style="width: 350px;">
          <el-input
            v-model="form.password"
            size="medium"
            placeholder="请输入密码"
          />
        </el-form-item>
        <!-- <el-form-item label="所属地区:" prop="address" style="width: 350px;">
          <el-input
            v-model="row.address"
            size="medium"
            placeholder="请输入所属地区"
          />
        </el-form-item> -->
      </el-form>
      <span slot="footer">
        <el-button
          @click="handleCancel"
        >
          取 消
        </el-button>
        <el-button
          type="primary"
          @click="handleConfirm"
        >
          确 定
        </el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import mixin from '@/mixin/mixin'

export default {
  name: 'PasswordDialog',
  mixins: [mixin],
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      title: '修改密码',
      form: {
        password: ''
      },
      rules: {
        password: [
          {
            required: true,
            message: '密码不能为空',
            trigger: 'blur'
          }
        ]
      }
    }
  },
  methods: {
    handleCancel() {
      this.$emit('cancel-dialog')
      this.$refs.passwordDialog.resetFields()
    },
    handleConfirm() {
      this.$refs.passwordDialog.validate((valid) => {
        if (valid) {
          this.$emit('confirm-dialog', {
            // dialog: this.$refs.garageDialog,
            password: this.form.password
          })
        } else {
          return false
        }
      })
    }
  }
}
</script>

<style>
</style>
